//
//  GYNewShopCollectCell.m
//  GYDemo
//
//  Created by Mrzhang on 2018/6/25.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYNewShopCollectCell.h"
#import "Head.h"

@interface GYNewShopCollectCell ()
@property (nonatomic,strong) UIImageView *imageIV;
@property (nonatomic,strong) UILabel *nameLB;
@property (nonatomic,strong) UILabel *priceLab;
@property (nonatomic,strong) UILabel *dealCountLab;
@property (nonatomic,strong) UILabel *levelLab;
@end
@implementation GYNewShopCollectCell

-(UIImageView *)imageIV
{
    if (!_imageIV) {
        _imageIV=[[UIImageView alloc] init];
        _imageIV.x=0;
        _imageIV.y=0;
        _imageIV.width=self.width;
        _imageIV.height=self.width;
        [WFFunctions addCornerToView:_imageIV radius:3 corner:UIRectCornerTopLeft|UIRectCornerTopRight];
        
        
    }
    return _imageIV;
}
-(UILabel *)nameLB
{
    if (!_nameLB) {
         _nameLB=[[UILabel alloc] init];
        _nameLB.x=WFCGFloatX(7);
        _nameLB.y=self.width+5;
        _nameLB.width=self.width;
        _nameLB.height=WFCGFloatY(20);
        _nameLB.font=SYSTEMFONT(14);
        _nameLB.textColor=HEXCOLOR(@"#333333");
    }
    return _nameLB;
}
-(UILabel *)priceLab
{
    if (!_priceLab) {
        _priceLab=[[UILabel alloc] init];
        _priceLab.x=WFCGFloatX(7);
        _priceLab.y=self.width+WFCGFloatY(41);
        _priceLab.width=self.width;
        _priceLab.height=WFCGFloatY(25);
        _priceLab.font=SYSTEMFONT(14);
        _priceLab.textColor=HEXCOLOR(@"#FC1B36");
    }
    return _priceLab;
}
-(UILabel *)dealCountLab
{
    if (!_dealCountLab) {
        _dealCountLab=[[UILabel alloc] init];
        _dealCountLab.x=WFCGFloatX(7);
        _dealCountLab.y=self.width+WFCGFloatY(69);
        _dealCountLab.width=self.width;
        _dealCountLab.height=WFCGFloatY(15);
        _dealCountLab.font=SYSTEMFONT(11);
        _dealCountLab.textColor=HEXCOLOR(@"#A4AAB3");
    }
    return _dealCountLab;
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self addSubview:self.imageIV];
        [self addSubview:self.nameLB];
        [self addSubview:self.priceLab];
        [self addSubview:self.dealCountLab];
    }
    return self;
}
-(void)setSourceModel:(GYNewGoodListModel *)model
{
    NSString* markStr=@"¥";
    NSString* money=[NSString stringWithFormat:@"%ld",model.price];
    NSString* price=[NSString stringWithFormat:@"%@%@",markStr,money];
    
    
    NSMutableAttributedString *mastr = [[NSMutableAttributedString alloc]initWithString:price];
    [mastr addAttribute:NSFontAttributeName value:SYSTEMFONT(10) range:[price rangeOfString:markStr]];
    [mastr addAttribute:NSFontAttributeName value:SYSTEMFONT(20) range:[price rangeOfString:money]];
    _priceLab.attributedText = mastr;
    
    [_imageIV sd_setImageWithURL:[NSURL URLWithString:model.picurl] placeholderImage:DefaultImage];
    _nameLB.text=model.name;
    _dealCountLab.text=[NSString stringWithFormat:@"销量:%ld 信誉等级:%@",model.salecount,model.xlevel];
}

@end
